local dye_table = dye.dyes

for i in ipairs(dye_table) do
   local name = dye_table[i][1]
   local desc = dye_table[i][2]
   local hex = dye_table[i][3]

   minetest.register_node('furniture:curtain_short_'..name..'_0', {
      description = 'Short '..desc..' Curtain Closed',
      drawtype = 'mesh',
      mesh = 'furniture_curtain_short.obj',
      tiles = {'furniture_curtain_short_0.png^[multiply:'..hex},
      paramtype = 'light',
      paramtype2 = 'facedir',
      drop = 'furniture:curtain_short_'..name..'_1',
      selection_box = {
         type = 'fixed',
         fixed = {-.5, -.5, .4, .5, .5, .5},
         },
      collision_box = {
         type = 'fixed',
         fixed = {-.5, -.5, .4, .5, .5, .5},
         },
      groups = {oddly_breakable_by_hand = 3, snappy=3, not_in_creative_inventory=1},
      on_rightclick = function(pos, node)
         minetest.set_node(pos, {name='furniture:curtain_short_'..name..'_1', param2 = node.param2})
      end
   })

   minetest.register_node('furniture:curtain_short_'..name..'_1', {
      description = 'Short '..desc..' Curtain Open',
      drawtype = 'mesh',
      mesh = 'furniture_curtain_short.obj',
      tiles = {'furniture_curtain_short_1.png^[multiply:'..hex},
      inventory_image = 'furniture_curtain_short_1.png^[multiply:'..hex,
      paramtype = 'light',
      paramtype2 = 'facedir',
      sunlight_propagates = true,
      selection_box = {
         type = 'fixed',
         fixed = {-.5, -.5, .4, .5, .5, .5},
         },
      collision_box = {
         type = 'fixed',
         fixed = {-.5, -.5, .4, .5, .5, .5},
         },
      groups = {oddly_breakable_by_hand = 3, snappy=3},
      on_rightclick = function(pos, node)
         minetest.set_node(pos, {name='furniture:curtain_short_'..name..'_0', param2 = node.param2})
      end
   })

   minetest.register_node('furniture:curtain_tall_'..name..'_0', {
      description = 'Tall '..desc..' Curtain Closed',
      drawtype = 'mesh',
      mesh = 'furniture_curtain_tall.obj',
      tiles = {'furniture_curtain_tall_0.png^[multiply:'..hex},
      paramtype = 'light',
      paramtype2 = 'facedir',
      drop = 'furniture:curtain_tall_'..name..'_1',
      selection_box = {
         type = 'fixed',
         fixed = {-.5, -1.3, .4, .5, .5, .5},
         },
      collision_box = {
         type = 'fixed',
         fixed = {-.5, -1.3, .4, .5, .5, .5},
         },
      groups = {oddly_breakable_by_hand = 3, snappy=3, not_in_creative_inventory=1},
      on_rightclick = function(pos, node)
         minetest.set_node(pos, {name='furniture:curtain_tall_'..name..'_1', param2 = node.param2})
      end
   })

   minetest.register_node('furniture:curtain_tall_'..name..'_1', {
      description = 'Tall '..desc..' Curtain Open',
      drawtype = 'mesh',
      mesh = 'furniture_curtain_tall.obj',
      tiles = {'furniture_curtain_tall_1.png^[multiply:'..hex},
      inventory_image = 'furniture_curtain_tall_1.png^[multiply:'..hex,
      paramtype = 'light',
      paramtype2 = 'facedir',
      sunlight_propagates = true,
      selection_box = {
         type = 'fixed',
         fixed = {-.5, -1.3, .4, .5, .5, .5},
         },
      collision_box = {
         type = 'fixed',
         fixed = {-.5, -1.3, .4, .5, .5, .5},
         },
      groups = {oddly_breakable_by_hand = 3, snappy=3},
      on_rightclick = function(pos, node)
         minetest.set_node(pos, {name='furniture:curtain_tall_'..name..'_0', param2 = node.param2})
      end
   })

end
